import { makeAutoObservable, runInAction } from 'mobx'
import { sleep } from '@/utils'

const user = makeAutoObservable({
  state: {
    uid: '',
    nickname: '',
  },

  login() {
    user.state.uid = 'the-uid'
    user.state.nickname = 'the name'
  },

  async logout() {
    await sleep()

    runInAction(() => {
      user.state.uid = ''
      user.state.nickname = ''
    })
  },
})

export default user
